//
//  AppDelegate.m
//  1yqb
//
//  Created by 曲天白 on 15/12/11.
//  Copyright © 2015年 乙科网络. All rights reserved.
//

#import "TopNavView.h"

@implementation TopNavView
-(id)initWithFrame:(CGRect)frame{
    if(self=[super initWithFrame:frame]){
        self.backgroundColor = Bai_Color;
        self.ViewTitle=[[UILabel alloc]initWithFrame:CGRectMake((IPHONE_W-200*WidthRate)/2, 20, 200*WidthRate, 44)];
        [self.ViewTitle setFont:[UIFont systemFontOfSize:18]];
        [self.ViewTitle setTextColor:[PublicMethod colorWithHexString:@"#666666" andAlpha:1]];
        self.ViewTitle.textAlignment=NSTextAlignmentCenter;
        [self addSubview:self.ViewTitle];
        
        self.LeftBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        self.LeftBtn.frame=CGRectMake(0,20, 44, 44);
        [self.LeftBtn addTarget:self action:@selector(LeftBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.LeftBtn];
        
        self.RightBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        self.RightBtn.frame=CGRectMake(IPHONE_W-44, 20, 44, 44);
        [self.RightBtn.titleLabel setFont:[UIFont systemFontOfSize:14]];
        [self.RightBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.RightBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        [self.RightBtn addTarget:self action:@selector(RightBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.RightBtn];
        
        _line=[[UIView alloc]initWithFrame:CGRectMake(0, frame.size.height-0.5, IPHONE_W, 0.5)];
        [_line setBackgroundColor:Line_Color];
        [self addSubview:_line];
    }
    
    return  self;
    
}
-(void)SetReftBtntitle:(NSString *)title{
    self.RightBtn.titleLabel.numberOfLines = 1;
    [self.RightBtn setTitle:title forState:UIControlStateNormal];
}


-(void)LeftBtnClick:(UIButton *)btn{
    if([self.delegate respondsToSelector:@selector(LeftBtnBackView:)]){
        [self.delegate LeftBtnBackView:btn];
    }
}
-(void)RightBtnClick:(UIButton *)btn{
    if([self.delegate respondsToSelector:@selector(RightBtnFuction:)]){
        [self.delegate RightBtnFuction:btn];
        
    }
}
-(void)SetReftBtnImg:(UIImage *)img{
    [self.RightBtn setImage:img forState:UIControlStateNormal];
}
-(void)SetLeftBtnImg:(UIImage *)img{
    [self.LeftBtn setImage:img forState:UIControlStateNormal];
}

-(void)SettitleColor:(UIColor *)color{
    [self.ViewTitle setTextColor:color];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/




@end
